<admintpl file="header" />
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li class="active"><a href="{:U('User/userinfo')}">{:L('ADMIN_USER_USERINFO')}</a></li>
			<li><a href="{:U('setting/password')}">{:L('ADMIN_SETTING_PASSWORD')}</a></li>
		</ul>
		<form class="form-horizontal js-ajax-form" method="post" action="{:U('User/userinfo_post')}">
			<fieldset>
				<div class="control-group">
					<label class="control-label" for="input-user_nicename">{:L('NICENAME')}</label>
					<div class="controls">
						<input type="hidden" name="id" value="{$user.id}">
						<input type="text" id="input-user_nicename" name="user_nicename" value="{$user.user_nicename}">
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="input-gender">{:L('GENDER')}</label>
					<div class="controls">
						<select name="sex" id="input-gender">
							<php>$sexs=array("0"=>L('GENDER_SECRECY'),"1"=>L('MALE'),"2"=>L('FEMALE'));</php>
							<foreach name="sexs" item="vo">
								<php>$sexselected=$key==$user['sex']?"selected":"";</php>
								<option value="{$key}"{$sexselected}>{$vo}</option>
							</foreach>
						</select>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="input-birthday">{:L('BIRTHDAY')}</label>
					<div class="controls">
						<input class="js-date" type="text" id="input-birthday" placeholder="2013-01-04" name="birthday" value="{$user.birthday}">
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="input-user_url">{:L('WEBSITE')}</label>
					<div class="controls">
						<input type="text" id="input-user_url" placeholder="http://wzx.thinkcmf.com" name="user_url" value="{$user.user_url}" maxlength="64">
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="input-user_email">{:L('EMAIL')}</label>
					<div class="controls">
						<input type="text" id="input-user_email" name="user_email" value="{$user.user_email}" maxlength="32">
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="input-signature">{:L('SIGNATURE')}</label>
					<div class="controls">
						<textarea id="input-signature" placeholder="{:L('SIGNATURE')}" name="signature">{$user.signature}</textarea>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="input-signature">{:L('MOBILE')}</label>
					<div class="controls">
						<input type="text" id="input-mobile" name="mobile" value="{$user.mobile}" maxlength="11">
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="input-signature">用户组</label>
					<div class="controls">
						<input type="text" value="{$role.name}" readonly="readonly">
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="input-signature">积分</label>
					<div class="controls">
						<input type="text" value="{$user.score}" readonly="readonly">
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="input-signature">头像</label>
					<div class="controls">
						<if condition="$user['avatar']">
								<input type="hidden" name="avatar" value="{$user.avatar}" width="128"/>
								<img src="{$urlimg}{$user.avatar}" name="avatar">
			        	</if>

						<input type="file" name="newavatar" id="imgfile" accept="image/*"/>
						<img src="" id="img" width="128">
					</div>
				</div>
				<div class="form-actions">
					<button type="submit" class="btn btn-primary js-ajax-submit">{:L('SAVE')}</button>
				</div>
			</fieldset>
		</form>
	</div>
	<script src="__PUBLIC__/js/common.js"></script>

	<script type="text/javascript">
	$("#imgfile").change(function(){
		var objUrl = getObjectURL(this.files[0]) ;
		console.log("objUrl = "+objUrl) ;
		if (objUrl) {
			$("#img").attr("src", objUrl) ;
		}
	}) ;
	function getObjectURL(file) {
		var url = null ;
		if (window.createObjectURL!=undefined) { // basic
			url = window.createObjectURL(file) ;
		} else if (window.URL!=undefined) { // mozilla(firefox)
			url = window.URL.createObjectURL(file) ;
		} else if (window.webkitURL!=undefined) { // webkit or chrome
			url = window.webkitURL.createObjectURL(file) ;
		}
		return url ;
	}
	</script>
</body>
</html>